﻿#region
/*******************************************************************************
** File Name:		    CategoryRepository.cs
** Creator:		        chao.jiang 
** EMail:               chao.jiang 
** Create date:	        
** Latest Modifier:
** Latest Modify date:
** Description:		    
** Modify History:
**
** Code Review:
**
** Version number:       1.0.0
*********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using Phoenix.Entity;
using Phoenix.Respository;
using IBatisNet.DataMapper;
using Phoenix.Data.IBatis;

namespace Phoenix.IBatisRepository
{
    public class CategoryRepository : BaseIBatisDao,ICategory
    {
    
		#region  Auto Generation

        public CategoryRepository()
            : base("/Config/IBatis/86TCMap.Config")
        {

        }
        		
        public void AddCategory(ECategory entity)
        {
			string stmtId = "CategoryMap.InsertCategory";
			base.SqlMapper.Insert(stmtId, entity);
        }
        
		public  ECategory GetByCategoryID (System.Int32 categoryID)
        {
			string stmtId = "CategoryMap.SelectByCategoryID";
			return base.SqlMapper.QueryForObject<ECategory>(stmtId, categoryID);
        }
        
        public  void DeleteByCategoryID (System.Int32 categoryID)
        {
			string stmtId = "CategoryMap.DeleteByCategoryID";
			base.SqlMapper.Update(stmtId, categoryID);
        }
        
        public  void UpdateByCategoryID (ECategory entity)
        {
			string stmtId = "CategoryMap.UpdateByCategoryID";
			base.SqlMapper.Update(stmtId, entity);
        }


		public  IList<ECategory> GetAll ()
        {
			string stmtId = "CategoryMap.SelectAll";
			return base.SqlMapper.QueryForList<ECategory>(stmtId,null);
        }

		#endregion

		public IList<ECategory> GetByParentID(int pid)
		{
			string stmtId = "CategoryMap.SelectByParentID";
            return base.SqlMapper.QueryForList<ECategory>(stmtId, pid);
		}

    }
}

